<template>


		<!-- <uni-card title="留不住的泪" sub-title="vip123123123" extra="设置" :thumbnail="avatar" @click="onClick"> -->
		<uni-card :title="userInfo.nickName" :sub-title="userInfo.userName" :thumbnail="imageUrl+userInfo.portrait" extra="设置"  @click="onClick">
			<uni-row class="demo-uni-row" >
				<uni-col :span="12">
					<view class="demo-uni-col dark">收入金币:{{userInfo.income}}</view>
				</uni-col>
				<uni-col :span="12">
					<view class="demo-uni-col light">已兑换金币:{{userInfo.expense}}</view>
				</uni-col>
			
			<!-- 	<uni-col :span="6">
					<view class="demo-uni-col light" >已签到</view>
				</uni-col> -->
			</uni-row>
				<text class="uni-body">{{userInfo.introduction}}</text>
		</uni-card>
	
	<uni-section title="任务列表" type="line">
		<uni-list>
			
			<uni-list-item v-if="userInfo.adStatus==1" title="赚金币" note="点击赚金币" showArrow
				thumb="../../static/tubiao5.png"
				thumb-size="lg" rightText=">" clickable @click="itemClick(1)" />
			<uni-list-item  title="兑换" note="金币兑换现金" showArrow
					thumb="../../static/tubiao5.png"
					thumb-size="lg" rightText=">"  clickable @click="itemClick(2)"/>
			<uni-list-item title="去发布分享" note="点击去发布分享(1金币)" showArrow
				thumb="../../static/tubiao1.png"
				thumb-size="lg" rightText=">"  clickable @click="itemClick(3)"/>
			<uni-list-item title="去发布待办" note="点击去发布待办(1金币)" showArrow
				thumb="../../static/tubiao2.png"
				thumb-size="lg" rightText=">"  clickable @click="itemClick(4)"/>
			<uni-list-item title="去发布目标" note="点击去发布目标(1金币)" showArrow
				thumb="../../static/tubiao3.png"
				thumb-size="lg" rightText=">"  clickable @click="itemClick(5)"/>
			<uni-list-item title="去发布提醒" note="点击去发布提醒(1金币)" showArrow
				thumb="../../static/tubiao4.png"
				thumb-size="lg" rightText=">"  clickable @click="itemClick(6)"/>
		</uni-list>
		</uni-section>
		<uni-fab ref="fab" :pattern="pattern" :content="toolsContent" :horizontal="horizontal" :vertical="vertical"
					:direction="direction" @trigger="trigger"  />
	
	
</template>

<script>
	import constant from '@/store/constant.js'

	const baseImageUrl=constant.baseImageUrl;
	import store from '@/store/index.js';//需要引入store
	export default {
		computed:{
			userInfo(){
				return store.state.user.userInfo
			},
			toolsContent(){
				return store.state.common.toolsContent
			},
		},
		components: {},
		onLoad() {
			//加载新闻通知数据
			store.dispatch('loadUserData',{})
			// uni.startPullDownRefresh();
			
			
		},
		
		data() {
			return {
				imageUrl:baseImageUrl,
				dosign:"签到",
				cover: '../../static/pig.png',
				avatar: '../../static/pig.png',
				extraIcon: {
					color: '#4cd964',
					size: '22',
					type: 'gear-filled'
				},
				title: 'uni-fab',
				directionStr: '垂直',
				horizontal: 'right',
				vertical: 'bottom',
				direction: 'horizontal',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				is_color_type: false,
				
			}
		},
		methods: {
			itemClick(type){
				let url="";
				switch(type){
					case 1:
						url="/pages/user/ad?userId="+this.userInfo.userId;
						break;
					case 2:
						url="/pages/user/pay?userId="+this.userInfo.userId+"&income="+this.userInfo.income;
						break;
					case 3:
						url="/pages/share/createShare";
						break;
					case 4:
						url="/pages/todo/createTodo";
						break;
					case 5:
						url="/pages/target/createTarget";
						break;
					case 6:
						url="/pages/alert/createAlert";
						break;
				
					
				}
				uni.navigateTo({
					url:url
				})
			},
			trigger(e) {
				
				this.toolsContent[e.index].active = !e.item.active
				store.dispatch('toolsJump',e.item.value)
			},
			onClick(e) {
				console.log(JSON.stringify(this.userInfo));
				let url="/pages/user/setting?userId="+this.userInfo.userId+"&nickName="+this.userInfo.nickName+"&introduction="+this.userInfo.introduction;
				url+="&pwd="+this.userInfo.pwd;
				if(this.userInfo.age!=undefined){
					url+="&age="+this.userInfo.age;
				}
				if(this.userInfo.sex!=undefined){
					url+="&sex="+this.userInfo.sex;
				}
				if(this.userInfo.birthday!=undefined){
					url+="&birthday="+this.userInfo.birthday;
				}
				if(this.userInfo.portrait!=undefined){
					url+="&portrait="+this.userInfo.portrait;
				}
				
				console.log(url);
				uni.navigateTo({
					url:url
				})
			},
			
		}
	}
</script>

<style>
	.demo-uni-row {
			margin-bottom: 10px;
	
		/* 	// 组件在小程序端display为inline
			// QQ、抖音小程序文档写有 :host，但实测不生效
			// 百度小程序没有 :host */
			/* #ifdef MP-TOUTIAO || MP-QQ || MP-BAIDU */
			display: block;
			/* #endif */
		}
	
	/* 	// 支付宝小程序没有 demo-uni-row 层级
		// 微信小程序使用了虚拟化节点，没有 demo-uni-row 层级 */
		/* #ifdef MP-ALIPAY || MP-WEIXIN */
		::v-deep .uni-row {
			margin-bottom: 10px;
		}
	
		/* #endif */
	
		.demo-uni-col {
			height: 36px;
			border-radius: 5px;
			line-height: 36px;
			text-align: center;
		}
	
		.dark_deep {
			background-color: #99a9bf;
		}
	
		.dark {
			background-color: #d3dce6;
		}
	
		.light {
			background-color: #e5e9f2;
		}
	
		.example-body {
			/* #ifndef APP-NVUE */
			display: block;
			/* #endif */
			padding: 5rpx 10rpx 0;
			overflow: hidden;
		}
</style>